package emp.jsf.servicio.impl;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import emp.entidades.EntCompraDet;
import emp.jsf.servicio.CompraDetService;
import emp.repositorios.CompraDetRepository;

@Service("CompraDetService")
public class CompraDetServiceImpl implements CompraDetService {

	@Autowired
	CompraDetRepository compraDetRepository;
	
	public List<EntCompraDet> listarCompraDet(){
		return compraDetRepository.findAll();
	}
	
	public EntCompraDet grabarCompraDet(EntCompraDet ent){
		return compraDetRepository.save(ent);
	}
	
	public void eliminar(EntCompraDet ent){
		compraDetRepository.delete(ent);
	}
	
	@Transactional
	@Override
	public List<EntCompraDet> listarDetallexCompra(long idCompra){
		List<EntCompraDet> lista= compraDetRepository.ListarDetalleCompra(idCompra);
		for(EntCompraDet d:lista){
			d.getEntArticulo();
		}
		return lista;
	}
}
